//
//  XRTabBarController.m
//  StupidFM
//
//  Created by 寒竹子 on 15/6/8.
//  Copyright (c) 2015年 寒竹子. All rights reserved.
//  自定义TabBarController

#import "XRTabBarController.h"
#import "MainViewController.h"
#import "RootNavigationController.h"
#import "AudioToolBar.h"

@interface XRTabBarController ()

@property (nonatomic, strong) AudioToolBar * audioToolBar; // 音乐迷你条

@end

@implementation XRTabBarController

- (instancetype)init
{
    if (self = [super init]) {
        // 注册通知
        [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(hiddenAudioToolBar) name:KHiddenAudioToolBarNotification object:nil];
    
        [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(showAudioToolBar) name:KShowAudioToolBarNotification object:nil];
    }
    
    return self;
}

- (void)setupTabBar
{
    MainViewController * mainVc = [[MainViewController alloc] init];
    RootNavigationController * rootNav = [[RootNavigationController alloc] initWithRootViewController:mainVc];
    NSMutableArray * viewControllers = [[NSMutableArray alloc] init];
    [viewControllers addObject:rootNav];
    
    self.viewControllers = viewControllers;
    
    [self.tabBar removeFromSuperview];
    
    _audioToolBar = [AudioToolBar sharedAudioToolBarWithFrame:CGRectMake(0, self.view.frame.size.height - 60.0f, self.view.frame.size.width, 60.0f)];
    [self.view addSubview:_audioToolBar];
}

#pragma mark - 隐藏/显示 AudioToolBar

/**
 * @brief  隐藏audioToolBar
 *
 * @param
 *
 * @return
 */
- (void)hiddenAudioToolBar
{
    if (!_audioToolBar.hidden) {
        _audioToolBar.hidden = YES;
    }
}

/**
 * @brief  显示audioToolBar
 *
 * @param
 *
 * @return
 */
- (void)showAudioToolBar
{
    if (_audioToolBar.hidden) {
        _audioToolBar.hidden = NO;
    }
}

- (void)viewDidLoad {
    [super viewDidLoad];
    
    [self setupTabBar];
}

- (void)didReceiveMemoryWarning {
    [super didReceiveMemoryWarning];
    
}

@end
